﻿<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link type="text/css" href="../Skin/Plane/css/List.css" rel="stylesheet" />
    <link rel="stylesheet" href="../Css/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="../Htc/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="../Htc/jquery.ztree.core.min.js"></script>
    <script type="text/javascript" src="../Htc/jquery.ztree.excheck.min.js"></script>
    <style>
        html {
            margin: 0px;
            height: 100%;
            overflow: hidden;
            *overflow: auto;
        }

        body {
            margin: 0px;
            height: 100%;
            overflow: hidden;
        }
    </style>
    <script type="text/javascript">
        var treeType;
        var showIcon = true;
        var showCheck = false;

        var setting = {
            view: {
                dblClickExpand: false,      //双击展开
                showLine: true,
                selectedMulti: false,       //选择多个,按ctrl
                showIcon: showIcon           //图标
            },
            check: {
                enable: showCheck   //复选
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "@ViewBag.Pg.KeyFieldName",
                    pIdKey: "@ViewBag.Pg.TreeParentFieldName",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function (treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    //			    if (treeNode.isParent) {
                    //			        //展开
                    //				    zTree.expandNode(treeNode);
                    //				    return false;
                    //			    }else {
                    //选择
                    $("#treeFrame").attr("src", "@(ViewBag.Pg.FileUrl)&@(ViewBag.Pg.KeyFieldName)=" + treeNode.@(ViewBag.Pg.KeyFieldName));
                    $("body").css("height", $("html").height());

                    //}
                }
            }
        };
        //加载
        $(document).ready(function () {
            $("body").css("height", $("html").height());
            //初始化
            $("#treeFrame").attr("src", "@(ViewBag.Pg.FileUrl)&@(ViewBag.Pg.KeyFieldName)=0");
            TreeLoadData();
        });
        function TreeLoadData() {
            $.ajax({
                url: "../Main/Tree/TreeData",
                dataType: "json",
                data: {
                    type: "@ViewBag.Pg.Type",
                    t: new Date().getTime()
                },
                success: function (data) {
                    $.fn.zTree.init($("#tree"), setting, data.data);
                    var treeObj = $.fn.zTree.getZTreeObj("tree");
                    var nodes = treeObj.getNodes();
                    if (nodes.length > 0) {
                        treeObj.selectNode(nodes[0]);
                        $("#treeFrame").attr("src", "@(ViewBag.Pg.FileUrl)&@(ViewBag.Pg.KeyFieldName)=" + nodes[0].@(ViewBag.Pg.KeyFieldName));
                        $("body").css("height", $("html").height());
                    }
                }
            });
        }
    </script>
</head>
<body class="BodyManager">
    <table class="treeTable">
        <tr>
            <td class="treeLeft"><img src="../Skin/Plane/images/t17.png" onclick="TreeLoadData()" class="treeReload"><div class="tree"><div id="tree" class="ztree"></div></div></td>
            <td class="treeFrame"><iframe id="treeFrame" frameborder="0"></iframe></td>
        </tr>
    </table>
</body>
</html>
